package com.payment.ktb.activity.main1;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;

import com.payment.ktb.R;
import com.payment.ktb.activity.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by syd on 2016/8/2.
 */
public class BanKaActivity extends BaseActivity {

    @BindView(R.id.wv_banka)
    WebView wv_banka;
//    String  bankaUrl = "https://wm.cib.com.cn/application/cardapp/Fast/TwoBar/view?id=52f93bb604a14b4fae5afbbec91b7120";
    String  bankaUrl = "http://m.rong360.com/credit/card/landing/4?code=6&utm_source=zjrf&utm_medium=xyk&utm_campaign=cpa";
//    String  bankaUrl = "http://ktb.4006007909.com/shop/bank/clb?token=" +  SharedPreferencesUtils.getString(ConstantsUser.shopToken);


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_banka);
        ButterKnife.bind(this);
        initTitle("办卡");
        wv_banka.loadUrl(bankaUrl);
        //支持js
        wv_banka.getSettings().setJavaScriptEnabled(true);
    //解决显示不全的问题
        wv_banka.getSettings().setDomStorageEnabled(true);



        wv_banka.setWebViewClient(new HelloWebViewClient ());
        LinearLayout llBack = (LinearLayout) findViewById(R.id.ll_title_back);
        llBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (wv_banka.canGoBack()) {
                    wv_banka.goBack();
                } else {
                    finish();
                }
            }
        });
    }



    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
//        @Override
//        public void onPageFinished(WebView view, String url) {
//            if (url.equals("https://wm.cib.com.cn/application/cardapp/Fast/BaseInfo/view")) {
//                String id = SharedPreferencesUtils.getString(SharedPreferencesUtils.getString(ConstantsUser.phone) + ConstantsUser.SHOPCERT);
//                view.loadUrl("javascript:document.getElementById('indentificationId').value=" + "'"+id + "'" );
//                view.loadUrl("javascript:document.getElementById('indentificationId').readOnly=true ");
//            }
//            super.onPageFinished(view, url);
//        }
    }




}
